/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ConfigAccGUI.java
 *
 * Created on Jun 15, 2009, 3:03:19 PM
 */
package GUI;

import BUS.AccountMailBUS;
import DAO.AccountMailDAO;
import DTO.AccountMailDTO;
import UTIL.ReadXML;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.AbstractListModel;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import org.xml.sax.SAXException;

/**
 *
 * @author NxSiHMr0D
 */
public class ConfigAccGUI extends javax.swing.JFrame {

    /** Creates new form ConfigAccGUI */
    public ConfigAccGUI() {
        initComponents();
    }
    AccountMailBUS _accBus = new AccountMailBUS();
    ArrayList<AccountMailDTO> _lstAccoutMail = new ArrayList<AccountMailDTO>();
    int _selectIDAcc;
    int _defaultIDAcc = -1;
    int _defaultProxy = -1;

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        txtuserName = new javax.swing.JTextField();
        txtIncommingServer = new javax.swing.JTextField();
        txtincomingserverType = new javax.swing.JTextField();
        txtEmail = new javax.swing.JTextField();
        btnAddNew = new javax.swing.JButton();
        btnDelete = new javax.swing.JButton();
        btnApply = new javax.swing.JButton();
        passWord = new javax.swing.JPasswordField();
        chkSetDefault = new javax.swing.JCheckBox();
        txtOutgoingServerMail = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        txtPort = new javax.swing.JTextField();
        chkSetProxy = new javax.swing.JCheckBox();
        jScrollPane1 = new javax.swing.JScrollPane();
        jListUserAcc = new javax.swing.JList();
        jLabel6 = new javax.swing.JLabel();

        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Detail Information"));
        jPanel1.setEnabled(false);

        jLabel1.setText("User Name");

        jLabel2.setText("Password");

        jLabel3.setText("Incomming server mail:");

        jLabel4.setText("Incoming server type:");

        jLabel5.setText("Email Adress :");

        btnAddNew.setText("Add New Account");
        btnAddNew.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAddNewActionPerformed(evt);
            }
        });

        btnDelete.setText("Delete Exist Account");
        btnDelete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDeleteActionPerformed(evt);
            }
        });

        btnApply.setText("Apply Change Info");
        btnApply.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnApplyActionPerformed(evt);
            }
        });

        chkSetDefault.setText("Set Default User( Active after restart program)");
        chkSetDefault.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chkSetDefaultActionPerformed(evt);
            }
        });

        jLabel7.setText("socks Proxy Host");

        jLabel9.setText("Port:");

        chkSetProxy.setText("Set Use Proxy ( Send and Receive Mail)");
        chkSetProxy.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chkSetProxyActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(chkSetDefault)
                    .addComponent(chkSetProxy)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(jLabel2))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(passWord)
                            .addComponent(txtuserName, javax.swing.GroupLayout.DEFAULT_SIZE, 227, Short.MAX_VALUE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(btnAddNew)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnDelete)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnApply))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addGap(14, 14, 14)
                        .addComponent(txtOutgoingServerMail, javax.swing.GroupLayout.PREFERRED_SIZE, 159, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtPort, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4)
                            .addComponent(jLabel3)
                            .addComponent(jLabel5))
                        .addGap(6, 6, 6)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(txtincomingserverType)
                            .addComponent(txtIncommingServer)
                            .addComponent(txtEmail, javax.swing.GroupLayout.DEFAULT_SIZE, 249, Short.MAX_VALUE)))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txtuserName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(passWord, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5))
                .addGap(11, 11, 11)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtIncommingServer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(txtincomingserverType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(11, 11, 11)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(txtOutgoingServerMail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9)
                    .addComponent(txtPort, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(chkSetProxy)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(chkSetDefault, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(25, 25, 25)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnAddNew)
                    .addComponent(btnDelete)
                    .addComponent(btnApply)))
        );

        jListUserAcc.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);
        jListUserAcc.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jListUserAccMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jListUserAcc);

        jLabel6.setText("User Account");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel6))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 305, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        // TODO add your handling code here:
        setResizable(false);
        jPanel1.setEnabled(false);
        try {
            _defaultProxy = ReadXML.getIDDefaultUser();
        } catch (ParserConfigurationException ex) {
            Logger.getLogger(ConfigAccGUI.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SAXException ex) {
            Logger.getLogger(ConfigAccGUI.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(ConfigAccGUI.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            _lstAccoutMail = _accBus.getListAccount();
            showListAccout(_lstAccoutMail);

        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(rootPane, "Get List User Failed !\n Detail" + ex.getMessage());
            Logger.getLogger(ConfigAccGUI.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            _defaultIDAcc = ReadXML.getIDDefaultUser();
        } catch (ParserConfigurationException ex) {
            Logger.getLogger(ConfigAccGUI.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SAXException ex) {
            Logger.getLogger(ConfigAccGUI.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(ConfigAccGUI.class.getName()).log(Level.SEVERE, null, ex);
        }

    }//GEN-LAST:event_formWindowOpened

    private void jListUserAccMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jListUserAccMouseClicked
        // TODO add your handling code here:
        int index = jListUserAcc.getSelectedIndex();
        if (index < 0) {
            jPanel1.setEnabled(false);
            return;
        }
        AccountMailDTO selectedAcc = _lstAccoutMail.get(index);
        _selectIDAcc = selectedAcc.getId();
        showInfoAcc(selectedAcc);

    }//GEN-LAST:event_jListUserAccMouseClicked

    private void btnAddNewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddNewActionPerformed
        // TODO add your handling code here:
        AccountMailDTO accountNew = getInfoAcc();
        if (accountNew == null) {
            return;
        }
        for (AccountMailDTO acc : _lstAccoutMail) {
            if (acc.getAccountName().equals(accountNew.getAccountName())) {
                JOptionPane.showMessageDialog(rootPane, "User already exists");
                return;
            }

        }
        try {

            int id = _accBus.insertAccountMail(accountNew);
             if ( chkSetDefault.isSelected())
                try {
                ReadXML.updateIDDefaultUser(id);
            } catch (ParserConfigurationException ex) {
                Logger.getLogger(ConfigAccGUI.class.getName()).log(Level.SEVERE, null, ex);
            } catch (SAXException ex) {
                Logger.getLogger(ConfigAccGUI.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(ConfigAccGUI.class.getName()).log(Level.SEVERE, null, ex);
            }  catch (TransformerConfigurationException ex) {
                Logger.getLogger(ConfigAccGUI.class.getName()).log(Level.SEVERE, null, ex);
            } catch (TransformerException ex) {
                Logger.getLogger(ConfigAccGUI.class.getName()).log(Level.SEVERE, null, ex);
            }
            if ( chkSetProxy.isSelected())
                try {
                ReadXML.updateProxy(1);
            } catch (ParserConfigurationException ex) {
                Logger.getLogger(ConfigAccGUI.class.getName()).log(Level.SEVERE, null, ex);
            } catch (SAXException ex) {
                Logger.getLogger(ConfigAccGUI.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(ConfigAccGUI.class.getName()).log(Level.SEVERE, null, ex);
            }  catch (TransformerConfigurationException ex) {
                Logger.getLogger(ConfigAccGUI.class.getName()).log(Level.SEVERE, null, ex);
            } catch (TransformerException ex) {
                Logger.getLogger(ConfigAccGUI.class.getName()).log(Level.SEVERE, null, ex);
            }
            _lstAccoutMail = _accBus.getListAccount();
            showListAccout(_lstAccoutMail);
            JOptionPane.showMessageDialog(rootPane, "Insert process Completed");
        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(rootPane, "Insert new User Failed !\n Detail" + ex.getMessage());
            Logger.getLogger(ConfigAccGUI.class.getName()).log(Level.SEVERE, null, ex);
        }

    }//GEN-LAST:event_btnAddNewActionPerformed

    private void btnDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteActionPerformed
        // TODO add your handling code here:
        AccountMailDTO accountNew = getInfoAcc();
        if (accountNew == null) {
            return;
        }
        Boolean exist = false;
        for (AccountMailDTO acc : _lstAccoutMail) {
            if (acc.getAccountName().equals(accountNew.getAccountName())) {
                //JOptionPane.showMessageDialog(rootPane, "User already exists");
                exist = true;
                break;
            }

        }

        try {
            if (exist == false) {
                JOptionPane.showMessageDialog(rootPane, "User doesn't exists");
                return;
            }
            accountNew = _accBus.getAccountMail(_selectIDAcc);
            _accBus.deleteAccountMail(accountNew);
            _lstAccoutMail = _accBus.getListAccount();
            showListAccout(_lstAccoutMail);
            JOptionPane.showMessageDialog(rootPane, "Delete process Completed");
        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(rootPane, "Delete User Failed !\n Detail" + ex.getMessage());
            Logger.getLogger(ConfigAccGUI.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_btnDeleteActionPerformed

    private void btnApplyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnApplyActionPerformed
        // TODO add your handling code here:
        try {
            try {
                ReadXML.updateIDDefaultUser(_defaultIDAcc);
                ReadXML.updateProxy(_defaultProxy);
            } catch (FileNotFoundException ex) {
                Logger.getLogger(ConfigAccGUI.class.getName()).log(Level.SEVERE, null, ex);
            } catch (TransformerConfigurationException ex) {
                Logger.getLogger(ConfigAccGUI.class.getName()).log(Level.SEVERE, null, ex);
            } catch (TransformerException ex) {
                Logger.getLogger(ConfigAccGUI.class.getName()).log(Level.SEVERE, null, ex);
            }
        } catch (ParserConfigurationException ex) {
            Logger.getLogger(ConfigAccGUI.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SAXException ex) {
            Logger.getLogger(ConfigAccGUI.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(ConfigAccGUI.class.getName()).log(Level.SEVERE, null, ex);
        }
        AccountMailDTO accountNew = getInfoAcc();
        if (accountNew == null) {
            return;
        }
        for (AccountMailDTO acc : _lstAccoutMail) {
            if (acc.getAccountName().equals(accountNew.getAccountName()) && _selectIDAcc == -1) {
                JOptionPane.showMessageDialog(rootPane, "User already exists");
                return;
            }

        }
        try {
            accountNew.setId(_selectIDAcc);
            _accBus.updateAccountMail(accountNew);
            _lstAccoutMail = _accBus.getListAccount();
            showListAccout(_lstAccoutMail);
            JOptionPane.showMessageDialog(rootPane, "Update Infomation User process Completed");
        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(rootPane, "Update User Failed !\n Detail" + ex.getMessage());
            Logger.getLogger(ConfigAccGUI.class.getName()).log(Level.SEVERE, null, ex);
        }


    }//GEN-LAST:event_btnApplyActionPerformed

    private void chkSetDefaultActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkSetDefaultActionPerformed
        // TODO add your handling code here:
        if (!chkSetDefault.isSelected()) {
            _defaultIDAcc = -1;
        } else {
            _defaultIDAcc = _selectIDAcc;
        }


    }//GEN-LAST:event_chkSetDefaultActionPerformed

    private void chkSetProxyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkSetProxyActionPerformed
        // TODO add your handling code here:
          if (!chkSetProxy.isSelected()) {
            _defaultProxy = -1;
        } else {
            _defaultProxy = 1;
        }

}//GEN-LAST:event_chkSetProxyActionPerformed
    private void showInfoAcc(AccountMailDTO account) {
        jPanel1.setEnabled(true);
        txtuserName.setText(account.getAccountName());
        passWord.setText(account.getPassword());
        txtIncommingServer.setText(account.getIncommingServerName());
        txtincomingserverType.setText(account.getIncomingServerType());
        txtEmail.setText(account.getMailAddress());
        txtOutgoingServerMail.setText(account.getOutgoingServerName());
        int proxy = account.getPortNumber();
        txtPort.setText(Integer.toString(proxy));
        //if ( _selectIDAcc == _defaultIDAcc)
        if (account.getId() ==_defaultIDAcc)
            chkSetProxy.setSelected(_defaultProxy != -1);
        else
            chkSetProxy.setSelected(false);

        chkSetDefault.setSelected(_selectIDAcc == _defaultIDAcc);
    }

    private AccountMailDTO getInfoAcc() {
        AccountMailDTO account = new AccountMailDTO();
        if (txtuserName.getText() == "") {
            JOptionPane.showMessageDialog(rootPane, "User Name can not be empty");
            return null;
        }
        if (passWord.getText() == "") {
            JOptionPane.showMessageDialog(rootPane, "PassWord can not be empty");
            return null;
        }
        account.setAccountName(txtuserName.getText());
        account.setPassword(passWord.getText());
        account.setIncommingServerName(txtIncommingServer.getText());
        account.setIncomingServerType(txtincomingserverType.getText());
        account.setMailAddress(txtEmail.getText());
        account.setOutgoingServerName(txtOutgoingServerMail.getText());
        account.setOutgoingUserName(txtPort.getText());
        try {
            int pr = Integer.parseInt(txtPort.getText());
            if (pr < 0) {
                return null;
            }
            account.setPortNumber(pr);

        } catch (Exception sx) {
            return null;
        }

        return account;
    }

    private void showListAccout(ArrayList<AccountMailDTO> lstMail) {
        DefaultListModel listModel = new DefaultListModel();
        for (AccountMailDTO account : lstMail) {
            listModel.addElement(account.getAccountName());
        }
        jListUserAcc.setModel(listModel);


    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new ConfigAccGUI().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAddNew;
    private javax.swing.JButton btnApply;
    private javax.swing.JButton btnDelete;
    private javax.swing.JCheckBox chkSetDefault;
    private javax.swing.JCheckBox chkSetProxy;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JList jListUserAcc;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JPasswordField passWord;
    private javax.swing.JTextField txtEmail;
    private javax.swing.JTextField txtIncommingServer;
    private javax.swing.JTextField txtOutgoingServerMail;
    private javax.swing.JTextField txtPort;
    private javax.swing.JTextField txtincomingserverType;
    private javax.swing.JTextField txtuserName;
    // End of variables declaration//GEN-END:variables
}
